package com.example.demo.concurrent.TimerTest;

import lombok.extern.slf4j.Slf4j;

import java.util.Timer;
import java.util.TimerTask;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2023-03-29
 * Time: 22:36
 */
@Slf4j(topic = "c.TestTimer")
public class TestTimer {

    public static void main(String[] args) {
        Timer timer = new Timer();

        TimerTask task1 = new TimerTask() {
            @Override
            public void run() {
                log.debug("task1");
                int x = 9/0;
            }
        };
        TimerTask task2 = new TimerTask() {
            @Override
            public void run() {
                log.debug("task2");
            }
        };
        log.debug("start");
        timer.schedule(task1,1000);
        timer.schedule(task2,1000);
    }
}